//
//  BrushEdVC.m
//  BrushFace
//
//  Created by timer_q on 15/12/31.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "BrushEdVC.h"
#import "NavHelper.h"

@interface BrushEdVC ()

@end

@implementation BrushEdVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.navBar setTitle:@"刷脸识钱途"];
    [self.navBar setLeftBtn:NAV_BAR_LEFT_BTN_TYPE_BLUE];
    self.headerImage.image = self.currentImage;
    self.headerImage.contentMode = UIViewContentModeScaleAspectFill;
    self.headerImage.clipsToBounds = YES;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.moneyLabel.text = [NSString stringWithFormat:@"%@",_outputDict[@"facemoney"]];
    self.zhuangBLabel.text = [NSString stringWithFormat:@"%@",_outputDict[@"facedesc"]];
    self.textLabel.text = [NSString stringWithFormat:@"你的颜值%@,击败了全国%@%%的用户",_outputDict[@"facenum"],_outputDict[@"facepercent"]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)shareBtnClick:(id)sender {
    
}
- (IBAction)borrowBtnClick:(id)sender {
    NSString *requestStr = [NSString stringWithFormat:@"%@/confirmfaceforapp.json",SERVICE_ADRESS];
    NSDictionary *params = @{@"faceid":[_outputDict objectForKey:@"id"]};
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        if ([[NSString stringWithFormat:@"%@",jsonObject[@"result"]] integerValue]==1) {
            [NavHelper gotoIWillBorrowVC];
        }else{
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:jsonObject[@"errormsg"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
            [alert show];
        }
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        
    }];
}
- (IBAction)backBtnClick:(id)sender {
    UIViewController * viewVC = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count - 3];
    [self.navigationController popToViewController:viewVC animated:YES];
}

- (void)leftButtonClick{
    [self backBtnClick:nil];
}
@end
